/////////////////////////////////////////////////////////////////////////////
//
// (c) 2007 BinaryComponents Ltd.  All Rights Reserved.
//
// http://www.binarycomponents.com/
//
/////////////////////////////////////////////////////////////////////////////

using System.Drawing;
using System.Windows.Forms;
using SuperListEx.Utility.Collections;

namespace SuperListEx.Sections
{
	public class AvailableColumnsSection : HeaderColumnSectionContainer
    {
        #region properties
        public override bool AllowColumnsToBeDroppedInVoid
        {
            get
            {
                return false;
            }
        }
        #endregion

        #region constructors
        public AvailableColumnsSection( ISectionHost host, EventingList<Column> columns )
			: base( host, columns )
		{
			columns.DataChanged += columns_DataChanged;
        }
        #endregion

        #region public functions
        public override bool CanDrop( IDataObject dataObject, CanDropQueryContext context )
		{
			return false;
		}

		public override bool ShouldRemoveColumnOnDrop( Column column )
		{
			return false;
		}

		public override void Layout( GraphicsSettings gs, Size maximumSize )
		{
			base.Layout( gs, maximumSize );
			Size = new Size( Size.Width, Children.Count == 0 ? 0 : Children[Children.Count - 1].Rectangle.Bottom - Rectangle.Top );
        }
        #endregion

        #region protected functions
        protected override HeaderColumnSection CreateHeaderColumnSection( DisplayMode displayModeToCreate, Column column )
		{
			return Host.SectionFactory.CreateAvailableColumnSection( Host, column );
        }
        #endregion  

        #region private functions
        private void columns_DataChanged( object sender, EventInfo<Column> e )
		{
			SyncSectionsToColumns( DisplayMode.Customise );
			Host.LazyLayout( null );
        }
        #endregion
    }
}